package com.polaris.live.viewmodel

import androidx.lifecycle.MutableLiveData
import com.polaris.live.common.mvvm.viewmodel.BaseViewModel
import com.polaris.live.common.network.request
import com.polaris.live.common.network.requestLoading
import com.polaris.live.common.network.state.ResultState
import com.polaris.live.net.homeService
import com.polaris.live.net.liveService
import com.polaris.live.net.payerService
import com.polaris.live.net.userService
import com.polaris.live.resp.back_resp.CoinBeansResp
import com.polaris.live.resp.back_resp.LiveShowMessageResp
import com.polaris.live.resp.back_resp.PartyRoomResp
import com.polaris.live.resp.back_resp.WithdrawAccountInfoVo
import com.polaris.live.resp.back_resp.WithdrawAccountResp
import com.polaris.live.resp.go_resp.LastWithdrawAccountResp
import com.polaris.live.resp.go_resp.SaveWithdrawAccountBean

/**
 * MyBeansViewModel
 *
 * @author Created by 半仙 on 2023/10/24/024 17:30
 */
class MyBeansViewModel : BaseViewModel() {

    val mCoinBeansLiveData = MutableLiveData<ResultState<CoinBeansResp>>()
    val mWithdrawAccountLiveData = MutableLiveData<ResultState<WithdrawAccountResp>>()
    val mDeleteWithdrawLiveData = MutableLiveData<ResultState<Any>>()
    val mWithdrawLiveData = MutableLiveData<ResultState<Any>>()
    val mSaveWithdrawLiveData = MutableLiveData<ResultState<Any>>()
    val mLastWithdrawLiveData = MutableLiveData<ResultState<LastWithdrawAccountResp>>()
    val mLiveShowLiveData = MutableLiveData<ResultState<LiveShowMessageResp>>()

    fun getMyBeans() {
        request({ userService.coinMyBeans() }, mCoinBeansLiveData)
    }

    /**
     * 查询提现账号信息
     */
    fun getWithdraw() {
        request({ payerService.getWithdraw() }, mWithdrawAccountLiveData)
    }

    /**
     * 删除提现账号
     */
    fun deleteWithdraw(accountId: Int) {
        requestLoading({ payerService.deleteWithdraw(accountId) }, mDeleteWithdrawLiveData)
    }

    /**
     * 提现V2
     */
    fun withdrawV2(withdrawBean: WithdrawAccountInfoVo) {
        requestLoading({ payerService.withdrawV2(withdrawBean) }, mWithdrawLiveData)
    }

    /**
     * 保存选中提现账户
     */
    fun saveWithdraw(saveWithdrawAccountBean: SaveWithdrawAccountBean) {
        requestLoading(
            { payerService.saveWithdraw(saveWithdrawAccountBean) },
            mSaveWithdrawLiveData
        )
    }

    /**
     * 获得最后选中提现账户
     */
    fun lastWithdraw() {
        request({ payerService.lastWithdraw() }, mLastWithdrawLiveData)
    }

    fun livesShowMessage() {
        request({ homeService.livesShowMessage() }, mLiveShowLiveData)
    }

    val mPartyRoomLiveData = MutableLiveData<ResultState<PartyRoomResp>>()
    fun getPartyRoom() {
        request({ liveService.getPartyRoom() }, mPartyRoomLiveData)
    }

}